
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<c:set var="ctx" value="${pageContext.request.contextPath}" />
<div class="bjui-pageContent">
	<form action="${ctx}/sys/sysCustomerAction/doSave" class="pageForm"
		data-toggle="validate"  autocomplete="off">
		<input type="hidden" name="op" id="j_dialog_op"
			value="${param.op}${op}"> <input type="hidden" name="id"
			id="j_dialog_id" value="${customer.id}">
		<c:if test="${!empty role}">
			<input type="hidden" name="status" id="j_dialog_op"
				value="${customer.status}">
		</c:if>

		<table class="table table-condensed table-hover">
			<tbody>
				<tr>
					<td colspan="2" align="center" valign="middle"><h4>${title}</h4></td>
				</tr>
				<tr>
					<td><label for="name" class="control-label x90">用户名称：</label>
						<input class="" id="customerName" type="text" name="customerName"
						value="${customer.customerName}"
						data-rule="required;" /><%-- name;remote[${ctx}/sys/sysCustomerAction/doCustomerNameValidate?op=${op}&original=${customer.customerName}] --%>
						</td>
						<td>
					<label for="name" class="control-label x90">登陆账户(手机号)：</label>

						<input class="" id="userName" type="text" name="userName" data-rule="required;mobile;remote[${ctx}/sys/sysCustomerAction/doCustomerMobileValidate?op=${op}&original=${customer.userName}]"
						 data-rule-mobile="[/(^1[3|5|7|8][0-9]{9}$)/, '请填写正确的手机号']" 
						 autocomplete="off" value="${customer.userName}" /></td>

				</tr>
				<tr>
					<td><label for="name" class="control-label x90">登录密码：</label>
						<c:choose>
							<c:when test="${param.op=='add'} or ${op=='add'}">
								 <input class="" id="userPassword" type="password" name="userPassword" 
								 data-rule="required;length[6~20];pwd;"
								 data-rule-pwd="[/(?!^[0-9]+$)(?!^[A-z]+$)(?!^[^A-z0-9]+$)^.{6,20}$/, '6~20位，由字母数字或特殊字符组成']"
								 autocomplete="new-password"  value="${customer.userPassword}" />
							</c:when>
							<c:otherwise>
								 <input class="" id="userPassword" type="password" name="userPassword" 
								 data-rule="required;length[6~20];pwd;"
								 data-rule-pwd="[/(^\*\*\*\*\*\*$)|(?!^[0-9]+$)(?!^[A-z]+$)(?!^[^A-z0-9]+$)^.{6,20}$/, '6~20位，由字母数字或特殊字符组成']"
								 autocomplete="new-password"  value="${customer.userPassword}" />
							</c:otherwise>
						</c:choose>
				
					</td>
					<td><label class="control-label x90">证件类型：</label>
						<select data-toggle="selectpicker" name="cardType">
				          <c:forEach  items= "${cardTypes}" var="cu">
				            	<option value="${cu.codeValue}" ${customer.cardType == cu.codeValue?"selected='selected'":""}>${cu.codeName}</option>					            
			              </c:forEach>
				        </select>
						</td>
					

				</tr>
				<tr>
					<td>
						<label for="name" class="control-label x90">证件号码：</label>
						<input class="" id="cardNum" type="text" name="cardNum"
						value="${customer.cardNum}" /></td>
					
					<td><label for="name" class="control-label x90">邮箱：</label> <input
						class="" id="email" type="text" name="email"
						value="${customer.email}" />
						</td>
						

				</tr>


				<tr>
					<td>
						<label for="name" class="control-label x90">联系固话：</label>
						<input class="" id="contactFixed" type="text" name="contactFixed"
						value="${customer.contactFixed}" /></td>
					<td>
						
					<label  class="control-label x90">归属人：</label>
					 <select id="distributorSelect" data-toggle="selectpicker" name="distributorId" onchange="getCompany()">
				          <c:forEach  items= "${distributors}" var="cu">
				            	<option value="${cu.id}" ${customer.distributorId == cu.id?"selected='selected'":""}>${cu.name}</option>					            
			              </c:forEach>
				        </select>
					</td>
				</tr>


				<tr>

					
					<td>
				        
					<label class="control-label x90">所属公司：</label> 
					<!-- <input id="distributor_companyId" type="hidden" name="companyId"  value="" readonly /> -->
					<label class="control-label" id="distributor_company">${empty customer.companyName?distributors[0].companyName:customer.companyName}</label>
					</td>
						<td colspan=2>
					<label class="control-label x90">支付账号：</label>
						<input class=""  type="text" name="payAccount"
						value="${customer.payAccount}" />
					</td>
				</tr>
				<tr>
					<td colspan=2><label for="name" class="control-label x90">备注：</label> <textarea
							name="remark" id="remark" rows="5" cols="58">${customer.remark}</textarea>
					</td>
				</tr>

			</tbody>
		</table>
	</form>
</div>
<script>
	var distributors = [];
	<c:forEach  items= "${distributors}" var="cu">
	distributors.push({
	        id: '${cu.id}',
	        name: '${cu.companyName}'
	    });					            
	</c:forEach>
	function getCompany()
	{
		console.log($("#distributorSelect").attr("value"));
		var id = $("#distributorSelect").attr("value");
		for (var i = 0 ; i<distributors.length; i++)
			{
				if(distributors[i].id == id)
					{
						$("#distributor_company").text(distributors[i].name);
					}
			}
	}
</script>
<div class="bjui-pageFooter">
	<ul>
		<li><button type="button" class="btn-close" data-icon="close">关闭</button></li>
		<li><button type="submit" class="btn-default" data-icon="save">保存</button></li>
	</ul>
</div>